import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;

import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.rdf.model.InfModel;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.reasoner.rulesys.GenericRuleReasoner;
import com.hp.hpl.jena.reasoner.rulesys.Rule;


public class TestReasoner {

		
		GenericRuleReasoner reasoner;

		OntModel ontModel;

		Resource configuration;

		InfModel infModel;
		
		public OntModel runEngine(String ruleFile, Model model) throws IOException {
			 
			ontModel = ModelFactory.createOntologyModel();

			List rules = Rule.rulesFromURL(ruleFile);
			reasoner = new GenericRuleReasoner(rules);
			reasoner.setOWLTranslation(true);
			reasoner.setTransitiveClosureCaching(true);

			// model = FileManager.get().loadModel(rdfFile);

			infModel = ModelFactory.createInfModel(reasoner, model);

			infModel.prepare();
			ontModel.add(infModel);
			
			FileOutputStream fout = new FileOutputStream("test7.owl");
			ontModel.write(fout);
			
			 return ontModel;
		}
	

}
